if ( SERVER ) then
	function GM:SetWon( bool )
		umsg.Start( "Incursion.GameWon" )
			umsg.Bool( bool )
		umsg.End()
		
		self:SetRoundTimer( 30 )
		timer.Simple( 30, function() game.ConsoleCommand( "changelevel " .. game.GetMap() .. "\n" ) end )
	end
	function GM:CheckWin()
		if ( !self:IsBuild() ) then return end
		
		if ( !self.GameWon && self:GetRoundNumber() >= self.TotalWaves ) then
			self:SetWon( true )
			
			self.GameWon = true
			
			timer.Simple( 30, function() game.ConsoleCommand( "changelevel " .. game.GetMap() .. "\n" ) end )
		end
	end
	GM:AddHook( "RoundChanged", "CheckWin" )
	
	function GM:CheckLose()
		local total, alive, dead = self:GeneratorStats()
		if ( alive == 0 ) then
			self:SetWon( false )
		end
	end
	GM:AddHook( "GeneratorDestroyed", "CheckLose" )
end
if ( CLIENT ) then
	function GM.ReceiveGameWon( msg )
		GAMEMODE.GameWon = msg:ReadBool()
		GAMEMODE:CallHook( "GameWon", GAMEMODE.GameWon )
	end
	usermessage.Hook( "Incursion.GameWon", GM.ReceiveGameWon )
end